<template>
	<view class="work-container">
		<!-- 轮播图 -->
		<uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
			<swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
				<swiper-item v-for="(item, index) in data" :key="index">
					<view class="swiper-item" @click="clickBannerItem(item)">
						<image :src="item.image" mode="aspectFill" :draggable="false" />
					</view>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>

		<!-- 宫格组件 -->
		<uni-section title="系统管理" type="line"></uni-section>
		<view class="grid-body">
			<uni-grid :column="2" :showBorder="false" @change="changeGrid">
				<uni-grid-item>
					<view class="grid-item-box grid-border-right">
						<image class="grid-icon" src="/static/images/medicine.png" />
						<text class="text">药品管理</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box">
						<image class="grid-icon" src="/static/images/symptom.png" />
						<text class="text">症状查询</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box grid-border-top grid-border-right">
						<image class="grid-icon" src="/static/images/report.png" />
						<text class="text">报告自检</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box grid-border-top">
						<image class="grid-icon" src="/static/images/consult.png" />
						<text class="text">专家会诊</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				swiperDotIndex: 0,
				data: [{
					image: '/static/images/qy.png'
				}]
			}
		},
		methods: {
			clickBannerItem(item) {
				console.info(item)
			},
			changeSwiper(e) {
				this.current = e.detail.current
			},
			changeGrid(e) {
				const index = e.detail.index
				let message = ''
				switch(index) {
					case 0:
						message = '药品管理建设中~'
						break;
					case 1:
						message = '症状查询建设中~'
						break;
					case 2:
						message = '报告自检建设中~'
						break;
					case 3:
						message = '专家会诊建设中~'
						break;
					default:
						message = '模块建设中~'
				}
				this.$modal.showToast(message)
			}
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	/* #endif */

	.text {
		text-align: center;
		font-size: 40rpx;
		margin-top: 10rpx;
		font-weight: bold;
	}

	.grid-body {
		padding: 0 20px;  /* 修改为内边距，左和右各20px */
	}

	.grid-item-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-border-top {
		border-top: 1px solid #dcdcdc;
	}

	.grid-border-right {
		border-right: 1px solid #dcdcdc;
	}

	.grid-border-bottom {
		border-bottom: 1px solid #dcdcdc;
	}

	.grid-border-left {
		border-left: 1px solid #dcdcdc;
	}

	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
	}

	.swiper {
		height: 400rpx;
	}

	.swiper-box {
		height: 240px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 400rpx;
		line-height: 400rpx;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			/* #ifndef APP-NVUE */
			margin: 0 auto;
			/* #endif */
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	.grid-icon {
		width: 120px; /* 适当调整图标的宽度 */
		height: 120px; /* 适当调整图标的高度 */
	}
</style>
